package com.pdwl.common.dtos;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
@ApiModel("分页数据请求")
public class PageRequestDto<T> {
    @ApiModelProperty(value = "页码显示大小",required = true,example = "5")
    private Integer size;
    @ApiModelProperty(value = "当前页",required = true,example = "1")
    private Integer page;
    @ApiModelProperty(value = "分页查询的条件",required = false)
    private T entity;

    public void checkParam() {
        if (this.page == null || this.page < 0) {
            setPage(1);
        }
        if (this.size == null || this.size < 0 || this.size > 100) {
            setSize(10);
        }
    }
}
